def goldensearch(a, b, func, eps, p = 0.618):
    a_s = a + (1-p)*(b-a)
    b_s = a + p * (b-a)
    if abs(a-b) < eps:
        return (a+b)/2           
    else:
        if func(a) > func(b):
            return goldensearch(a_s, b, func, eps, p)
        else:
            return goldensearch(a, b_s, func, eps, p)

import sys
sys.setrecursionlimit(1000)
result = goldensearch(a = -3.,b = 5.,func = lambda t: t*(t + 2), eps = 0.1, p = 0.618)
print(result)